<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta charset="utf8">
<title>推聊</title>

<style>
body{
color: #333;
font-family: arial;
font-size: 14px;
background: #EEE;
margin:0;
}
.item-list {
border-top: 1px solid #DDD;
border-bottom: 1px solid white;
margin: 0;
padding: 0;
list-style: none;
}
.item-list li {
height: 44px;
overflow: hidden;
border-top: 1px solid white;
border-bottom: 1px solid #DDD;
line-height: 44px;
text-indent: 10px;
font-size: 14px;
}
.comm-tag a.tag-red {
background-color: #FF8D81;
color: white;
}
.comm-tag a {
display: inline-block;
border: 1px #DDD solid;
border-radius: 4px;
-webkit-border-radius: 4px;
font-size: 12px;
color: #666;
background-color: white;
height: 24px;
line-height: 24px;
padding: 0 5px;
margin: 6px 6px 0 0;
text-decoration: none;
font-family: verdana;
}
.innercontent{
margin:10px;
}
</style>
</head>


<body onload="init();">
<div class="innercontent">
	<#if info ??>
	<span style="color:blue;">${info}</span> <br/>
	</#if>
	<#if error ??>
	<span style="color:red;">${error}</span><br />
	</#if>
	<div>
		<div>欢迎您：${user.name}！</div>
		<div class="comm-tag">
			<a href="/user/changeName?udid=${udid}">改名</a>
			<a href="/channel/new?udid=${udid}">新频道</a>
			<a href="/channel?udid=${udid}">全部频道</a>
		</div>
	</div>

	<h3>最近聊天</h3>
	<ul class="item-list">
	<#list recentChats as chat>
		<li>
		<#assign chatting = chat.getChatTarget(user.name)>
		<#if chat.isChannel()>
		<#assign chattingShow = '#' + chatting>
		<#else>
		<#assign chattingShow = '@' + chatting>
		</#if>
		
		<#if (chat.unReadNumber > 0) >
		<b><a href="/chatting?chatting=${chatting}&isChannel=${chat.getIsChannel()}">${chattingShow}</a>
		(${chat.unReadNumber})</b>
		<#else>
		<a href="/chatting?chatting=${chatting}&isChannel=${chat.getIsChannel()}">${chattingShow}</a>
		</#if>
		
		<#if chat.isToday() >
		<font color="gray">${chat.lastUpdated?time?string.short}</font>
		<#else>
		${chat.lastUpdated?date?string.short}
		</#if>
		</li>
	</#list>
	</ul>
	
	<h3>我的频道</h3>
	<ul class="item-list">
	<#list myChannelList as channel>
		<li><a href="/chatting?chatting=${channel.name}&isChannel=true">#${channel.name}</a></li>
	</#list>
	</ul>
</div>
<div id="debug"></div>

<script type="text/javascript">
var UDID;
var CLIENT_OS;
var HOST;
var PATH_CHATTING = "/chatting";

function urlParam(name) {
    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
    if (null == results) return "";
    return results[1];
}

function init(){
	CLIENT_OS = urlParam('os');
	UDID = urlParam('udid');
	HOST = urlParam('host');
	
	var debug = document.getElementById("debug");
}

<#if channelCreated ?? || channelDeleted ??>
pushtalk.channelUpdated();
</#if>
<#if usernameUpdated ??>
pushtalk.usernameUpdated();
</#if>
</script>

</body>
</html>
